from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QLabel, QVBoxLayout
from PySide6.QtGui import QFont
from PySide6.QtCore import Qt, QTimer, QSize

import sys

class LoadingWindow(QWidget):
    def __init__(self):
        super().__init__()
        # 设置窗口最小尺寸
        self.appWindow = None
        self.setMinimumSize(QSize(500, 180))
        self.label = QLabel('加载中...')
        self.label.setFont(QFont('微软雅黑', 50))
        self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.layout = QVBoxLayout()
        self.layout.addWidget(self.label)
        self.setLayout(self.layout)

        # 一次性延迟事件， 模拟加载时间
        QTimer.singleShot(3000, self.openAppWindow)

    def openAppWindow(self):
        self.close()
        self.appWindow = MyApp()
        self.appWindow.show()
        # self.close()

class MyApp(QMainWindow):
    def __init__(self) -> None:
        super().__init__()
        self.setWindowTitle("MyWindow")
        button = QPushButton("Press me")

        self.setCentralWidget(button)

if __name__ == '__main__':
    app = QApplication(sys.argv)

    window = LoadingWindow()
    window.show()

    app.exec()